


public class MyHandler {
    private MyLooper mlooper;
    private MyMessageQueue mqueue;

    public MyHandler() {
        mlooper = MyLooper.myLooper();
        if (mlooper == null) {
            throw new RuntimeException("not looper.prepare");
        }
        mqueue = mlooper.mqueue;
    }

    public final void sendMessage(MyMessage myMessage) {
        MyMessageQueue queue = mqueue;
        if (queue != null) {
            myMessage.target = this;
            queue.enqueueMessage(myMessage);

        }else{
            throw new RuntimeException("sendmessage called no mqueue");
        }
    }

    public void handmessage(MyMessage msg){}

    public void dispatchMessage(MyMessage msg){
        handmessage(msg);
    }
}
